package org.example.projectdemo.model.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;

import java.time.LocalTime;

@Getter
@Setter
@Entity
@Table(name = "course", schema = "projectfrist")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Course {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

    @NotBlank(message = "课程代码不能为空")
    @Column(name = "course_code", nullable = false)
    private String courseCode;

    @NotBlank(message = "课程名称不能为空")
    @Column(name = "course_name", nullable = false)
    private String courseName;

    @NotBlank(message = "教师姓名不能为空")
    @Column(name = "teacher_name", nullable = false)
    private String teacherName;

    @NotNull(message = "上课星期不能为空")
    @Column(name = "day_of_week", nullable = false)
    private Byte dayOfWeek;//存储1-7，1代表周一，7代表周日，前端根据这个数字去显示对应的中文。

    @NotNull(message = "开始时间不能为空")
    @Column(name = "start_time", nullable = false)
    private LocalTime startTime;//只包含时间,例如：14:30:00

    @NotNull(message = "结束时间不能为空")
    @Column(name = "end_time", nullable = false)
    private LocalTime endTime;

    @NotBlank(message = "教室不能为空")
    @Column(name = "classroom", nullable = false)
    private String classroom;

    @ColumnDefault("'active'")
    @Column(name = "course_state")
    private String courseState;

}